home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3481 / 3481.xpi / components / GlueProtocol.js
Text File  |  2010-01-14  |  3KB  |  1 lines

  1. const kSCHEME="glue";const kPROTOCOL_NAME="Glue Protocol";const kPROTOCOL_CONTRACTID="@mozilla.org/network/protocol;1?name="+kSCHEME;const kPROTOCOL_CID=Components.ID("B28A492D-F80A-4EE5-BE0D-27E1EB27CB40");const kSIMPLEURI_CONTRACTID="@mozilla.org/network/simple-uri;1";const kIOSERVICE_CONTRACTID="@mozilla.org/network/io-service;1";const nsISupports=Components.interfaces.nsISupports;const nsIIOService=Components.interfaces.nsIIOService;const nsIProtocolHandler=Components.interfaces.nsIProtocolHandler;const nsIURI=Components.interfaces.nsIURI;function GlueProtocol(){}GlueProtocol.prototype={QueryInterface:function(iid){if(!iid.equals(nsIProtocolHandler)&&!iid.equals(nsISupports)){throw Components.results.NS_ERROR_NO_INTERFACE}return this},scheme:kSCHEME,defaultPort:-1,protocolFlags:nsIProtocolHandler.URI_NORELATIVE|nsIProtocolHandler.URI_NOAUTH|nsIProtocolHandler.URI_LOADABLE_BY_ANYONE,allowPort:function(port,scheme){return false},getURIFlags:function(aURI){return Components.interfaces.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT},newURI:function(spec,charset,baseURI){var topWindow=this.getTopWindow();try{var new_url=Components.classes["@mozilla.org/network/standard-url;1"].createInstance(Components.interfaces.nsIStandardURL);new_url.init(1,-1,spec,charset,baseURI);return new_url.QueryInterface(nsIURI)}catch(e){topWindow.Glue.LogUtils.error("Glue.Protocol.newChannel",e);return false}},newChannel:function(aURI){var topWindow=this.getTopWindow();try{topWindow.Glue.ProtocolHandler.request(aURI.spec)}catch(e){topWindow.Glue.LogUtils.error("GlueProtocol.newChannel",e)}return false},getTopWindow:function(){var windowManager=Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);return windowManager.getMostRecentWindow("navigator:browser")}};var GlueProtocolFactory=new Object();GlueProtocolFactory.createInstance=function(outer,iid){if(outer!=null){throw Components.results.NS_ERROR_NO_AGGREGATION}if(!iid.equals(nsIProtocolHandler)&&!iid.equals(nsISupports)){throw Components.results.NS_ERROR_NO_INTERFACE}return new GlueProtocol()};var GlueModule=new Object();GlueModule.registerSelf=function(compMgr,fileSpec,location,type){compMgr=compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);compMgr.registerFactoryLocation(kPROTOCOL_CID,kPROTOCOL_NAME,kPROTOCOL_CONTRACTID,fileSpec,location,type);var catMgr=Components.classes["@mozilla.org/categorymanager;1"].getService(Components.interfaces.nsICategoryManager);catMgr.addCategoryEntry("JavaScript global property",kSCHEME,kPROTOCOL_CONTRACTID,true,true)};GlueModule.getClassObject=function(compMgr,cid,iid){if(!cid.equals(kPROTOCOL_CID)){throw Components.results.NS_ERROR_NO_INTERFACE}if(!iid.equals(Components.interfaces.nsIFactory)){throw Components.results.NS_ERROR_NOT_IMPLEMENTED}return GlueProtocolFactory};GlueModule.canUnload=function(compMgr){return true};function NSGetModule(compMgr,fileSpec){return GlueModule};